home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
FFT and Complex Numbers Library
/
FFTLibrary.sit
/
FFT library ƒ
/
FFT.h
< prev
next >
Wrap
Text File
|
1995-01-15
|
4KB
|
126 lines
//
// File: FFT.h
// Copyright ⌐1994-1995 James Wilson
// All rights reserved.
//
// This is the header file for FFT.cp, an implementation of the Fast
// Fourier Fransform (FFT).
#ifndef __FFT__
#define __FFT__
#if macintosh
#if defined(powerc)
#include <math.h>
#else
#if defined(__SC__)
#if __option(mc68881)
#include <math.h>
#else
#ifndef __SANE__
#include <SANE.h>
#endif
#endif
#else
#include <math.h>
#endif
#endif
#else
#include <math.h>
#endif
#ifndef __COMPLEXNUMBERS__
#include "ComplexNumbers.h"
#endif
// 2*pi is equal to one revolution in radians (equivalent to 360 degrees).
const double twoPi = 6.28318530717959;
typedef Complex *ComplexArray;
/*
Function name: FFT
Returns: none
Parameters:
n: the number of data points in the spectrumOut array. n should
always be a power of 2.
nu: nu should satisfy this equation: n = 2^nu. ^ signifies power
not the binary XOR operator. In other words, nu is log2 of
n.
spectrumOut: on input, the real fields of the elements in this
array should hold the input values of the time-waveform to
be analyzed, with all the imaginary fields set to 0. On
output, this array holds the complex values of the Fourier
transform of the input. Input data is destroyed.
Notes: This function is an implementation of the Fast Fourier
transform, a function that takes any sampled function and
breaks in up into sine and cosine components. It is
particularly useful in digital signal processing and the
analysis of sound waves.
*/
extern void FFT(const long n, const long nu, ComplexArray spectrumOut);
/*
Function name: IFFT
Returns: none
Parameters:
n and nu: these variables serve the same purpose as they do
in the function FFT (see above).
functionOut:On input, the elements of this array should hold the
complex Fourier transform values that are to be
transformed back into function values.
Notes: This function performs an Inverse Fourier transform; it takes
the transform values and creates a function out of it. The
IFFT is defined seperately from the FFT for pure computational
speed. Please be aware that the inverse values may not equal
the original values exactly. This is because anything that
uses the transcendental functions (sine, cosine, etc.) will
never be exact, however the inverse values should close
enough not to notice a significant difference.
*/
extern void IFFT(const long n, const long nu, ComplexArray functionOut);
/*
Function name: BitReverse
Returns: long
Possible return values: theNum, with its binary digits reversed.
Parameters:
theNum: the number that is to be reversed.
nu: the number of significant bits in theNum. This paramter
is similar to the nu paramter in the FFT function (see
above).
Notes: This function produces a number that is the binary reverse of
the input, theNum. For example, calling BitReverse with
theNum = 011001 and nu = 6 results with 100110. This function
is used internally by the function FFT.
*/
extern long BitReverse(const long theNum, const long nu);
/*
Function name: LongPower
Returns: long
Possible return values: base, raised to the power exp.
Parameters:
base: the base that is to be raised by exp.
exp: the exponent.
Notes: Power functions are not well defined in C/C++, so for
simplicity and compatibility, I define my own. Its operation
is staightforward, and probably not of that much interest to
applications.
*/
extern long LongPower(const long base, const long exp);
#endif